package application.LoginAndAdministrationModule;

import java.math.BigInteger;
import java.security.MessageDigest;


public class Szyfr
{

	Szyfr(){}
	/*
	 * MD5 - rodzaj szyfrowania
	 * http://docs.oracle.com/javase/6/docs/api/java/security/MessageDigest.html
	 * http://pl.wikipedia.org/wiki/MD5
	 */
	public String encrypt (String haslo)
	{
		try
		{
			MessageDigest md5_hash = MessageDigest.getInstance("MD5");
			md5_hash.update(haslo.getBytes(),0,haslo.length()); // input, offset, length
			BigInteger tmp = new BigInteger(1,md5_hash.digest());
			String haslo_tmp=tmp.toString(16);
			return haslo_tmp;
		}
		catch (Exception e)
		{
			return null;
		}
	}
	
}
